package com.project.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.project.bean.DisasterPrevention.EventBean;
import com.project.bean.ExpertConsultation.ConsultBean;
import com.project.mapper.IEventMapper;
import com.project.service.IEventService;
import com.project.service.IExpertService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.time.LocalDate;
import java.util.List;

@RestController
@RequestMapping("event")
public class EventController {


    @Resource
    private IEventService eventService;

    @RequestMapping("findCutEvent")
    public IPage<EventBean> findCutEvent(@RequestParam(value = "pageNo",defaultValue = "1") int pageNo, @RequestParam(value = "pageSize",defaultValue = "3") int pageSize, String eventName, String eventStage, String regionName, LocalDate startDate, LocalDate endData) {

        IPage<EventBean> page = eventService.findCutEvent(pageNo,pageSize,eventName,eventStage,regionName,startDate,endData);


        return page;
    }

    @RequestMapping("addEvent")
    public String addEvent(EventBean eventBean) {

        if (eventBean != null){
            eventService.addEvent(eventBean);
        }
        ;
        return "ok";
    }

    @RequestMapping("findEvent")
   public EventBean findEvent(int eventId) {

        EventBean eventBean = eventService.findEvent(eventId);

        return eventBean;
    }

    @RequestMapping("updateEvent")
    public String updateEvent(int eventId,String eventStage,String eventPrecept) {

        eventService.updateEvent(eventId,eventStage,eventPrecept);

        return "yes";
    }


    @RequestMapping("findAllEvent")
    public List<EventBean> findAllEvent() {

        List<EventBean> list = eventService.findAllEvent();

        return list;

    }



    @RequestMapping("updateEventStage")
    public String updateEventStage(int eventId,String eventStage) {

        eventService.updateEventStage(eventId,eventStage);

        return "yes";
    }


    @RequestMapping("findConsult")
    public EventBean findConsult(int eventId){

        EventBean eventBean = eventService.findConsult(eventId);

        return eventBean;

    }

}
